package com.kerrykidz.filemanagement.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.kerrykidz.filemanagement.service.IVisitorService;
import com.kerrykidz.system.dao.model.SecUsrEntity;
import com.kerrykidz.system.service.IUserService;
import com.rdp.framework.exception.RDPException;

/**
 * 访客管理控制器
 * @author YANAN
 *
 */
@Controller
@RequestMapping("filemanagement")
public class VisitorController {

	@Autowired
	private IVisitorService visitorService;
	@Autowired
	private IUserService userService;
	
	/**
	 * 跳转到访客管理
	 * @return
	 * @throws RDPException 
	 */
	@RequestMapping("/viewVistors")
	public ModelAndView viewVistors() throws RDPException{
		List<Map<String,Object>> list=visitorService.viewVistors(null, null);
		return new ModelAndView("file/file_visitor", "list", list);
	}
	
	/**
	 * 跳转到访客管理列表模式
	 * @return
	 * @throws RDPException 
	 */
	@RequestMapping("/listVistors")
	@ResponseBody
	public List<Map<String,Object>> listVistors() throws RDPException{
		List<Map<String,Object>> list=visitorService.viewVistors(null,null);
		return list;
	}
	
	/**
	 * 访客管理列表查询
	 * @return
	 * @throws RDPException 
	 */
	@RequestMapping("/searchListVistors")
	@ResponseBody
	public List<Map<String,Object>> searchListVistors(@RequestParam(value = "condition",required=false) String condition,
			@RequestParam(value = "relatedSales") String relatedSales) throws RDPException{
		List<Map<String,Object>> list=visitorService.viewVistors(condition, relatedSales);
		return list;
	}
	
	/**
	 * 获取所有销售信息
	 * @return
	 * @throws RDPException 
	 */
	@RequestMapping("/listSales")
	@ResponseBody
	/*public List<Map<String,Object>> listSales() throws RDPException{
		List<Map<String,Object>> list=visitorService.listSales();
		return list;
	}*/
	public List<SecUsrEntity> listSales() throws RDPException{
		List<SecUsrEntity> list=userService.listUserByRoleId("106");
		return list;
	}
}
